package cn.itcast.gateway.config;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import reactor.core.publisher.Mono;

/**
 * gateway限流配置
 */
@Configuration
public class RateLimiterConfiguration{


    /**
     * 根据ip限流
     * @return
     */
    @Bean(value = "ipKeyResolver")
    public KeyResolver ipKeyResolver(){
        return exchange -> {
           return Mono.just(exchange.getRequest().getURI().getPath());
        };
    }


}
